import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int year = in.nextInt();
        int month = in.nextInt();
        int day = in.nextInt();
        //判断是否为闰年
        boolean isyear = false;
        int sum = 0;
        //闰年
        if((year%4 == 0 && year%100 != 0) || year % 400 == 0) {
            isyear = true;
        }
        //平年
        int[] arr1 = {0,31,59,90,120,151,181,212,243,273,304,334};
        //闰年
        int[] arr2 = {0,31,60,91,121,152,182,213,244,274,305,335};
        if(!isyear) {
            System.out.println(arr1[month-1] + day);
        }else {
            System.out.println(arr2[month-1] + day);
        }
        
    }
}